package com.jumper.study.admin.service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jumper.study.admin.dto.req.OrderSearchReq;
import com.jumper.study.admin.dto.resp.ChartData;
import com.jumper.study.db.dto.OrderDto;
import com.jumper.study.db.model.Order;
import com.jumper.study.db.model.OrderOperate;
import com.jumper.study.db.model.OrderStatus;

public interface OrderService extends BaseService<Order> {
    /**
     * 分页搜索订单
     * @param page
     * @param req
     * @return
     */
    IPage<OrderDto> pageSearchWithAccountAndLesson(IPage<OrderDto> page, OrderSearchReq req);

    /**
     * 读取订单 
     * @param id
     * @return
     */
    OrderDto getWithAccountAndLessonById(Long id);

    /**
     * 更新订单价格
     * @param entity
     * @param newPrice
     * @param adminId
     * @return
     */
    boolean updatePrice(Order entity, Integer newPrice, Long adminId);

    /**
     * 订单通过并开通课程
     * @param entity
     * @param adminId
     * @return
     */
    boolean complete(Order entity, Long adminId);

    /**
     * 订单取消并关闭课程
     * @param entity
     * @param adminId
     * @return
     */
    boolean cancel(Order entity, Long adminId);

    /**
     * 读取操作列表
     * @param id
     * @return
     */
    List<OrderOperate> listOperaters(Long id);

    /**
     * 读取状态变化列表
     * @param id
     * @return
     */
    List<OrderStatus> listStatuses(Long id);

    /**
     * 订单数量
     * @param start
     * @param end
     * @return
     */
    Long orderCount(LocalDateTime start, LocalDateTime end);

    default Long orderCount() {
        return orderCount(null, null);
    }

    ChartData orderCountByDay(LocalDate date, int days);
}
